package cn.cxj.system.controller;

import cn.cxj.basic.util.PageList;
import cn.cxj.system.domain.Log;
import cn.cxj.system.query.LogQuery;
import cn.cxj.system.service.ILogService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 日志接口
 * @author 陈鑫杰
 * @date 2022年1月26日12:44:07
 */
@RestController
@RequestMapping("/log")
@Api(tags = "日志接口",description = "日志接口详细描述")
public class LogController {

    @Autowired
    private ILogService logService;

    /**
     * 基于id查询 GET
     * @param id 日志id
     * @return
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "日志查询",notes = "查询时需要携带的id")
    public Log findById(@PathVariable("id") Long id){
        return logService.queryById(id);
    }

    /**
     * 获取所有 GET
     * @return
     */
    @GetMapping("/list")
    @ApiOperation(value = "查询全部日志")
    public List<Log> findAll(){
        return logService.queryAll();
    }


    /**
     * 分页和高级查询 POST
     * @param query 查询参数
     * @return
     */
    @PostMapping("/page")
    @ApiOperation(value = "分页查询和高级查询",notes = "查询时需要携带的参数")
    public PageList<Log> pageQuery(@RequestBody LogQuery query){
        return logService.queryPage(query);
    }

}
